Section 3: Creating a Spatial Database¶
PgAdmin¶
PostgreSQL has a number of administrative front-ends. The primary is psql a command-line tool for entering SQL queries. Another popular PostgreSQL front-end is the free and open source graphical tool pgAdmin. All queries done in pgAdmin can also be done on the command line with psql.
Find PgAdmin and start it up.
If this is the first time you have run pgAdmin, you should have a server entry for PostGIS (localhost:5432) already configured in pgAdmin. Double click the entry, and enter anything you like at the password prompt to connect to the database.
The PostGIS database has been installed with unrestricted access for local users (users connecting from the same machine as the database is running). That means that it will accept any password you provide. If you need to connect from a remote computer, the password for the postgres user has been set to postgres.
Creating a Database¶
Open the Databases tree item and have a look at the available databases. The postgres database is the user database for the default postgres user and is not too interesting to us.
Right-click on the Databases item and select New Database.
Fill in the New Database form as shown below and click OK.
Name nyc Owner postgres
Select the new nyc database and open it up to display the tree of objects. You’ll see the public schema.
Click on the SQL query button indicated below (or go to Tools > Query Tool).
Enter the following query into the query text field to load the PostGIS spatial extension:
CREATE EXTENSION postgis;
Click the Play button in the toolbar (or press F5) to “Execute the query.”
Now confirm that PostGIS is installed by running a PostGIS function:
SELECT postgis_full_version();
You have successfully created a PostGIS spatial database!!
Function List¶
PostGIS_Full_Version: Reports full postgis version and build configuration info.
About Boundless
Boundless provides commercial open source software for internet mapping and geospatial application development. We are dedicated to the growth and support of open source software.
License
This work is licensed under a Creative Commons Non Commercial-Attribution-Share Alike 3.0 United States License. Feel free to use this material, but we ask that you please retain the Boundless branding, logos and style.

